@isTest
public class ConferenceItemsControllerTest
{
    static testMethod void ConferenceItemsControllerTest()
    {
        Campaign c=new Campaign();
        c.Name='迈克开放日';
        c.ActivitySite__c='成都';
        c.AnnualBudgetTypes__c='年度预算内活动';
        insert c;
        
        String cid=c.Id;
        ConferenceItems__c ci  = new ConferenceItems__c();
        ci.Name = 'P1.2_简版产品目录';
        ci.ConferenceItems__c = 'P1.2_简版产品目录';
        ci.MarketingActivities__c = cid;
        ci.Remarks__c = '';
        ci.Number__c = 1;
        insert ci;
        
        // ---------------------新建-----------------------
        PageReference page = new PageReference('/apex/ConferenceItems?cid=' + cid);
        System.Test.setCurrentPage(page);
        ConferenceItemsController cic=new ConferenceItemsController(new ApexPages.StandardController(new ConferenceItems__c()));
        cic.init();
        //System.assertEquals(0, 0);
        System.assertEquals(1, cic.qpbList.size()); 

        ConferenceItems__c ci2  = new ConferenceItems__c();
        ci2.Name = 'P1.1_产品目录（英文）';
        ci2.ConferenceItems__c = 'P1.1_产品目录（英文）';
        ci2.MarketingActivities__c = cid;
        ci2.Remarks__c = '';
        ci2.Number__c = 222;
        insert ci2;
        
        cic.ItemName='产品目录（英文）';
        cic.ItemCategory='P1.1';
        cic.search();
        System.assertEquals(1, cic.pbList.size());

        
        cic.pbList[0].chk = true;
        cic.exchange();
        System.assertEquals(2, cic.qpbList.size());
        
        cic.save();
        List<ConferenceItems__c> q = [select Id from ConferenceItems__c where MarketingActivities__c = :cid];
        System.assertEquals(2, q.size());
        
    }
}